#!/bin/bash

# 成功校验
function check(){
    if [ $? -ne 0 ];then
        exit $1
    fi
}

tmp=$1
tag=${tmp// /}
git_version=$(git tag -n --sort=-taggerdate | grep $tag | head -1)
times_num=$2

git checkout -b $git_version

image_version=${git_version// /}
version="$image_version-$times_num"
# 构建版本号
echo "构建版本号:" $version

# 发布dubbo-interface接口包
cd dubbo-interface
mvn clean deploy -Denv.project.version=$version -DskipTests
check 1
cd ..

# 编译dubbo服务端应用
cd dubbo-service
mvn clean deploy -Denv.project.version=$version -P$tag -DskipTests
check 1
cd ..

# 编译dubbo应用
cd dubbo-web
mvn clean deploy -Denv.project.version=$version -P$tag -DskipTests
check 1
cd ..

